<template>
  <view class="user">
       <!-- #ifdef MP-TOUTIAO -->
       <UserInfo :userInfo="userInfo" />
      <WorksSelect />
         <!-- #endif -->

   <!-- #ifdef H5 -->
   <UserInfo :code="code" />
    <UserIncome />
    <Team />
    <Guidance />

    <image src="@/static/h5/hh-bg.png"
     style="width: 100%; position: absolute;top: 0;"  mode="widthFix"/>

    <view style="position: relative;width: 100%;">
      <fui-footer text="潮象潮玩 © 2024 dmnuo.com"></fui-footer>
    </view>
    <!-- #endif -->
  </view>
</template>

<script setup lang="ts">
// #ifdef MP-TOUTIAO 
import UserInfo from "./components/UserInfo.vue";
import WorksSelect from "./components/WorksSelect.vue";
import dyUserPlayingService from "@/api/dyUserPlayingService";
import  type{ IGetUserInfoByCodeResponse } from "@/api/model/dyUserCodeModel";
import playingStore from "@/store/playing";
const userInfo = ref<IGetUserInfoByCodeResponse>()
const playing = playingStore()
// #endif

// #ifdef H5 
import UserInfo from "./components/H5/UserInfo.vue";
import userStore from "@/store/user";
import UserIncome from "./components/H5/UserIncome.vue";
import Guidance from "./components/H5/Guidance.vue";
import dyUserCodeService from "@/api/dyUserCodeService";
import Team from "./components/H5/Team.vue";

const code = ref()
const user = userStore()
// #endif

onLoad(async( data:any)=>{

  // #ifdef MP-TOUTIAO 
  try{
    const {result} = await dyUserPlayingService.getUserInfoByCode({code:data.code})
    userInfo.value = result
    playing.userId = result.id
    playing.code = data.code
    // dyUserPlayingService.viewUser({userId:Number(result.id)})
    // 

  }catch(e:any){
    uni.showToast({
        title: e.message,
        duration: 2000,
        icon:"none"
      });
  }
  // #endif
// #ifdef H5
  try {
    const {result,success} = await dyUserCodeService.getOne()
    code.value = result
    user.code = result
  } catch (error) {
    uni.showToast({
        title: '登录过期，重新登录',
        icon: 'none',
        mask: true,
        duration: 1000,
        complete: () => {
          setTimeout(() => {
            uni.reLaunch({
              url: `/pages/login/login`,
            })
          }, 1000)
        },
      })
  }
  // #endif
})
</script>
 <!-- #ifdef MP-TOUTIAO  -->
<style>
  page{
    height: 100%;
    width: 100%;
 
  }
</style>
 <!-- #endif -->
<style lang="scss" scoped>
.user{
  // #ifdef MP-TOUTIAO 
    color: white;
    padding: 20rpx;
    background: #000;
    height: 100%;
    // #endif

     // #ifdef H5
     background: rgb(248,248,248); 
     height: 100%;
     padding-bottom: 20rpx;
      // #endif
}
.app{
  background: rgb(248,248,248); 
}
</style>
